package com.bi.autotest.operations;

import com.auto.base.OperateAppium;
import com.bi.autotest.pages.H5LoginPage;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

/**
 * Created by yidian on 2018/4/13.
 */
public class H5LoginOperation extends OperateAppium {

    private H5LoginPage h5LoginPage;

    public H5LoginOperation(AndroidDriver androidDriver) {
        super(androidDriver);
        h5LoginPage=new H5LoginPage(androidDriver);
    }

    public boolean isHasNoOpenStore(){
        return h5LoginPage.isHasNoOpenStore();
    }

    public boolean isHasErrorVCode(){
        return h5LoginPage.isHasErrorVCode();
    }

    public boolean isHasNoVCode(){
        return h5LoginPage.isHasNoVCode();
    }

    public boolean isHasNoPhone(){
        return h5LoginPage.isHasNoPhoneText();
    }

    public boolean isHasPhoneError(){
        return h5LoginPage.isHasPhoneErrorText();
    }

    public boolean isChangeFlavorSuccess(){
        ggChangeFlavor();
        return h5LoginPage.isHasApplyOpen();
    }

    public boolean isChangeUserSuccess(){
        QWERChangeUser();
        return h5LoginPage.isHasApplyOpen();
    }

    public void ggChangeFlavor(){
        h5LoginPage.getGG_ChangeButton().click();
        sleep(3000);
        AndroidElement ae=h5LoginPage.getQWER_ChangeButton();
        ae.click();
        sleep(5000);
    }

    public void QWERChangeUser() {
        if(h5LoginPage.isHasApplyOpen()){
            h5LoginPage.getQWER_ChangeButton().click();
            sleep(3000);
            AndroidElement ae=h5LoginPage.getUser_ChangeButton();
            ae.click();
            sleep(3000);
            AndroidElement ae2= h5LoginPage.getOperator_ChangeButton();
            ae2.click();
            sleep(3000);
        }

    }

    /**
     * 点击错误提示的确定按钮
     */
    public void clickConfirmButton(){
        h5LoginPage.getConfirmButton().click();
        sleep(2000);
    }

    /**
     * 没有开店的情况下点击提示页面中登录按钮
     */
    public void clickLoginButton_noRegist(){
        h5LoginPage.getNoOpenLoginButton().click();
        sleep(3000);
    }

}
